package com.whnk.web.controller.pm;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.whnk.framework.web.base.BaseController;
import com.whnk.framework.web.page.TableDataInfo;
import com.whnk.pm.domain.BaseInfo;
import com.whnk.pm.domain.IdleResult;
import com.whnk.pm.service.IBaseInfoService;
import com.whnk.pm.service.IIdleResultService;

/**
 * 人员缺勤信息统计
 * 
 * @author whwhnk
 * @date 2019-08-29
 */
@Controller
@RequestMapping("/pm/idleTotal")
public class IdleTotalController extends BaseController
{
    private String prefix = "pm/idleTotal";
	
	@Autowired
	private IIdleResultService idleResultService;
	
	@Autowired
	private IBaseInfoService baseInfoService;
	
	@RequiresPermissions("pm:idleTotal:view")
	@GetMapping()
	public String idleTotal()
	{
	    return prefix + "/idleTotal";
	}
	
	/**
	 * 查询人员缺勤列表
	 */
	@RequiresPermissions("pm:idleTotal:total")
	@PostMapping("/total")
	@ResponseBody
	public TableDataInfo total(IdleResult idleResult)
	{
		startPage();
        List<IdleResult> list = idleResultService.queryIdleResultTotal(idleResult);
		return getDataTable(list);
	}
	
	/**
	 * 查看缺勤明细信息
	 * 
	 * @param empId
	 * @param mmap
	 * @return
	 */
	@GetMapping("/detail/{empId}")
    public String detail(@PathVariable("empId") String empId, ModelMap mmap)
    {
		BaseInfo baseInfo = baseInfoService.selectBaseInfoById(empId);
		mmap.put("baseInfo", baseInfo);
        return "pm/idleResult/idleResult";
    }
	
}
